﻿//报警reload任务，包括时间和执行函数
var alarm_reload;
//最新的报警store
var Unrecognized_store;
//上一次的报警store，可以和最新的报警store比较差异
var LastUnrecognized_store;
//比较前后的报警store，获取的报警数量
var intNewAlarmCount = 0;
//确认的报警store
var Confirmed_store;
//是否显示报警信息，1显示，0不显示 houruixian 默认不展示报警信息
var jingqing = 0;
//弹出的是第几个冒泡窗体
var abc = 0;
//TipsWindow[]--冒泡窗体数组
var tipw = [];
var t1 = 0;
//选定确认的警情
var dq_jingqing_id;

function iniAlarm() {
    alarmstoreload();
    alarm_reload = {
        run: alarmstoreload, //执行任务时执行的函数
        interval: 120000//任务间隔，毫秒为单位，这里是30秒
    };

    Ext.TaskMgr.start(alarm_reload);
}
var loadable = 0;
function alarmstoreload() {
    if (loadable == 0) {
        loadable = 1;
        return;
    }
    //TODO:比较是否有新的报警产生，弹出提示
    Unrecognized_store.load({
    params: { clientNo: userClientNo,currentService:currentService, op: 'getStore' },
        callback: function(records, options, success) {
            callbackalarmstore(records, options, success);
        }
    });


    //alert(intNewAlarmCount);
}

function callbackalarmstore(records, options, success) {
    //            window.frames["movemark"].clearMarkers();
    //            for (var i = 0; i <= records.length - 1; i++) {
    //                window.frames["movemark"].createfontmarker(records[i].get("Lng"), records[i].get("Lat"), records[i].get("LicensePlate") + "," + records[i].get("CardNo"));
    //            }
    //            if (records.length > 0) {
    //                window.frames["movemark"].mgrrefresh();
    //            }
}

function createAlarmPanel() {

    rsm2 = new Ext.grid.RowSelectionModel({
        singleSelect: true//只允许单选						
    });

    rsm3 = new Ext.grid.RowSelectionModel({
        singleSelect: true//只允许单选						
    });

    Unrecognized_rt = Ext.data.Record.create([

	{ name: 'VID' },
	{ name: 'LICENSE_PLATE' },
	{ name: 'SIMCARD_NO' },
    { name: 'ALARM_LOCATION' },
    { name: 'ALARM_TIME' },
	{ name: 'LONGITUDE' },
	{ name: 'LATITUDE' },
	{ name: 'ALARM_TYPE' },
	{ name: 'ROWID' }
	]);

    Unrecognized_store = new Ext.data.Store({
        url: "./Json/JsonGetAlarmInfoList.ashx",
        reader: new Ext.data.JsonReader(
    {
        root: 'data'
    },
			Unrecognized_rt // recordType
		)
    })

    LastUnrecognized_store = new Ext.data.Store({
        url: '',
        reader: new Ext.data.JsonReader(
    {
        root: 'data'
    },
			Unrecognized_rt // recordType
		)
    })



if (currentService == "5") {
    Unrecognized_grid = new Ext.grid.GridPanel({
        //renderTo: "Unrecognizedgrid",
        columns: [
	new Ext.grid.RowNumberer({
	    header: "",
	    //width　:　25,  
	    renderer: function (value, metadata, record, rowIndex) {
	        if (record.get("wxzt") == 0) {
	            return "<img src='images/terminalstate1.gif' title='定位无效'>";
	        } else {
	            return "<img src='images/terminalstate.gif' title='定位有效'>";
	        }
	    }
	}),
        //	{ header: "车辆编号", dataIndex: "VID", width: 60 },
	{header: "名称", dataIndex: "LICENSE_PLATE", width: 80 },
    { header: "报警类型", dataIndex: "ALARM_TYPE", width: 60 },
        //	{ header: "通讯卡号", dataIndex: "SIMCARD_NO", width: 90 },
	{header: "报警时间", dataIndex: "ALARM_TIME", renderer: renderDate, width: 120 },
    { header: "报警位置", dataIndex: "ALARM_LOCATION", width: 60 },
	{ header: "经度", dataIndex: "LONGITUDE", width: 80 },
	{ header: "纬度", dataIndex: "LATITUDE", width: 75 },

        //	{ header: "ROWID", dataIndex: "ROWID", width: 0 }
	],
        store: Unrecognized_store,
        sm: rsm2
        //autoExpandColumn:7//指定自动填充表格剩余区域的列id
    });
} else {
    Unrecognized_grid = new Ext.grid.GridPanel({
        //renderTo: "Unrecognizedgrid",
        columns: [
	new Ext.grid.RowNumberer({
	    header: "",
	    //width　:　25,  
	    renderer: function (value, metadata, record, rowIndex) {
	        if (record.get("wxzt") == 0) {
	            return "<img src='images/terminalstate1.gif' title='定位无效'>";
	        } else {
	            return "<img src='images/terminalstate.gif' title='定位有效'>";
	        }
	    }
	}),
	{ header: "车辆编号", dataIndex: "VID", width: 60 },
	{ header: "车辆名称", dataIndex: "LICENSE_PLATE", width: 80 },
	{ header: "通讯卡号", dataIndex: "SIMCARD_NO", width: 90 },
	{ header: "报警位置", dataIndex: "ALARM_LOCATION", width: 60 },
	{ header: "报警时间", dataIndex: "ALARM_TIME", renderer: renderDate, width: 120 },
	{ header: "经度", dataIndex: "LONGITUDE", width: 80 },
	{ header: "纬度", dataIndex: "LATITUDE", width: 75 },
	{ header: "报警类型", dataIndex: "ALARM_TYPE", renderer: GetAlarmTypeString, width: 60 },
	{ header: "ROWID", dataIndex: "ROWID", width: 50 }
	],
        store: Unrecognized_store,
        sm: rsm2
        //autoExpandColumn:7//指定自动填充表格剩余区域的列id
    });
}
    //加载之前
    Unrecognized_grid.getStore().addListener(
        {
            beforeload: function(store) {
                copyAlarmStore();
                //alert("beforeload");
            },
            load: function(store) {
                getNewAlarmCount();
                //alert("load");
            }
        });

        if (currentService != 5) {
            Unrecognized_grid.addListener('rowcontextmenu', rightClickFn1); //右键菜单代码关键部分
            //    Unrecognized_grid.addListener('rowdblclick', rightClickFn1); //右键菜单代码关键部分
            rightClick1 = new Ext.menu.Menu({
                id: 'rightClickCont1',
                items: [
			{
			    id: 'jrMenu1',
			    handler: querenjingqing,
			    text: '确认'
			}
		]
            });
        }
Unrecognized_grid.addListener('rowdblclick', function (grid, rowIndex, columnIndex, e) {//单击，可以把celldblclick换成cellclick
        
                var dataStore = grid.getStore();
                var myRcd = dataStore.getAt(rowIndex);
                showNotifyCarInfo(myRcd);
        //    }
    });

            function showNotifyCarInfo(rcd) {
//                if (curVID != rcd.get('VID')) {
//                    document.getElementById("monitor").contentWindow.removeline();
//                }

//                var curVID = rcd.get('VID');
//                var curCardNo = rcd.get('SIMCARD_NO');
//                var curLicensePlate = rcd.get('LicensePlate');

                var notifyCarInfo = "<B><font color='#CC9900'>" + rcd.get('LICENSE_PLATE') + "</font></B><BR><div id='meuncontl' style='text-decoration:none'></div>报警时间: " + rcd.get('ALARM_TIME') + "<BR>" + "报警类型: " + GetAlarmTypeString(rcd.get('ALARM_TYPE')) + "<BR>地址：解析中<br>&nbsp;";

//                if (monitortype == 2) {
                    window.frames["monitor"].setterminalinfo(notifyCarInfo);
                    window.frames["monitor"].setinfowindow_state(1);
                    window.frames["monitor"].setCenter(rcd.get('LONGITUDE'), rcd.get('LATITUDE'));
                    window.frames["monitor"].getAddress(rcd.get('LONGITUDE'), rcd.get('LATITUDE'), 1, true);
                    //20120524 WUP 修改手机图标更新成车辆图标
//                    if (rcd.get("CarType") == "手机") {
                    window.frames["monitor"].createMarkerALARM(rcd.get('LONGITUDE'), rcd.get('LATITUDE'));
//                    }
//                    else {
//                        window.frames["monitor"].setIconName(rcd.get('SIMCARD_NO'), getDirectionIconNameWithType(record.get("Direction"), record.get("CarType")));
//                    }
//                    window.frames["monitor"].resetLatLng(rcd.get('LONGITUDE'), rcd.get('LATITUDE'), rcd.get('CardNo'), notifyCarInfo);
////                }
////                else {
////                    window.frames["3dmonitor"].resetLatLng(rcd.get('Lng'), rcd.get('Lat'), curLicensePlate, notifyCarInfo);
////                }
            }



    /* 20120410伍鹏
    Unrecognized_grid.addListener('cellclick', function(grid1, rowIndex, columnIndex, e) {//单击，可以把celldblclick换成cellclick
    if (movemarkloadmap == 1) {
    sel_terminalnodeid = 0;
    var MyRecord = Unrecognized_store.getAt(rowIndex);
    sel_terminalinfo = "<B><font color='" + getcolor1(MyRecord.get('wxzt'), 1) + "'>" + MyRecord.get('terminalname') + "</font></B><BR><div id='meuncontl' style='text-decoration:none'></div>" + "IMEI:" + MyRecord.get('mobile') + "<BR>" + "速度：" + MyRecord.get('sd') + "公里/小时<BR>" + "方向：" + MyRecord.get('fx') + "<br>" + "时间：" + MyRecord.get('gpstime') + "<BR>" + "经纬：" + MyRecord.get('jdx') + "," + MyRecord.get('wdy') + "<BR>地址：解析中<br>&nbsp;";
    window.frames["movemark"].setterminalinfo(sel_terminalinfo);
    window.frames["movemark"].setinfowindow_state(1);

                var gettreenode = tree.getNodeById(MyRecord.get('terminalid'));
    gettreenode.select();

                var sindex = store.find("id", MyRecord.get('terminalid'))
    if (sindex != -1) {
    rsm.selectRow(sindex);
    var gv = grid.getView();
    gv.focusRow(sindex);
    }
    if ((MyRecord.get('jpjdx') != 0) && (MyRecord.get('jpwdy') != 0)) {
    window.frames["movemark"].setCenter(MyRecord.get('jpjdx'), MyRecord.get('jpwdy'));
    window.frames["movemark"].setLatLng2(MyRecord.get('jpjdx'), MyRecord.get('jpwdy'));
    window.frames["movemark"].getAddress(MyRecord.get('jpjdx'), MyRecord.get('jpwdy'), 1);
    } else {
    window.frames["movemark"].setCenter(MyRecord.get('jdx'), MyRecord.get('wdy'));
    window.frames["movemark"].setLatLng2(MyRecord.get('jdx'), MyRecord.get('wdy'));
    window.frames["movemark"].getAddress(MyRecord.get('jdx'), MyRecord.get('wdy'), 1);
    }
    window.frames["movemark"].openInfoWindow();
    window.frames["movemark"].selmarker_show();
    }

        });
    */


    //Unrecognized_grid.hide();

    Confirmed_store = new Ext.data.Store({
        url: '',
        reader: new Ext.data.JsonReader(
    {
        root: 'data'
    },
			Unrecognized_rt // recordType
		)
    })

    Confirmed_grid = new Ext.grid.GridPanel({
        height: 800,
        columns: [
	new Ext.grid.RowNumberer({
	    header: "",
//	    width　:　2500,  
	    renderer: function(value, metadata, record, rowIndex) {
	        if (record.get("wxzt") == 0) {
	            return "<img src='images/terminalstate1.gif' title='定位无效'>";
	        } else {
	            return "<img src='images/terminalstate.gif' title='定位有效'>";
	        }
	    }
	}),
	{ header: "车辆编号", dataIndex: "VID", width: 60 },
	{ header: "车辆名称", dataIndex: "LICENSE_PLATE", width: 80 },
	{ header: "通讯卡号", dataIndex: "SIMCARD_NO", width: 90 },
	{ header: "报警位置", dataIndex: "ALARM_LOCATION", width: 0 },
	{ header: "报警时间", dataIndex: "ALARM_TIME", renderer: renderDate, width: 120 },
	{ header: "经度", dataIndex: "LONGITUDE", width: 80 },
	{ header: "纬度", dataIndex: "LATITUDE", width: 75 },
	{ header: "报警类型", dataIndex: "ALARM_TYPE", renderer: GetAlarmTypeString, width: 60 }

	],
        store: Confirmed_store,
        sm: rsm3//,
        //autoExpandColumn:2//指定自动填充表格剩余区域的列id
    });
    Confirmed_grid.addListener('rowcontextmenu', rightClickFn2); //右键菜单代码关键部分
    Confirmed_grid.addListener('rowdblclick', rightClickFn2); //右键菜单代码关键部分

    rightClick2 = new Ext.menu.Menu({
        id: 'rightClickCont2',
        items: [
			{
			    id: 'jrMenu2',
			    handler: clearjingqing,
			    text: '删除'
			}
		]
    });

    //    Confirmed_grid.addListener('cellclick', function(grid1, rowIndex, columnIndex, e) {//单击，可以把celldblclick换成cellclick
    //        if (movemarkloadmap == 1) {
    //            sel_terminalnodeid = 0;
    //            var MyRecord = Confirmed_store.getAt(rowIndex);
    //            sel_terminalinfo = "<B><font color='" + getcolor1(MyRecord.get('wxzt'), 1) + "'>" + MyRecord.get('terminalname') + "</font></B><BR><div id='meuncontl' style='text-decoration:none'></div>" + "IMEI:" + MyRecord.get('mobile') + "<BR>" + "速度：" + MyRecord.get('sd') + "公里/小时<BR>" + "方向：" + MyRecord.get('fx') + "<br>" + "时间：" + MyRecord.get('gpstime') + "<BR>" + "经纬：" + MyRecord.get('jdx') + "," + MyRecord.get('wdy') + "<BR>地址：解析中<br>&nbsp;";
    //            window.frames["movemark"].setterminalinfo(sel_terminalinfo);
    //            window.frames["movemark"].setinfowindow_state(1);
    //            var gettreenode = tree.getNodeById(MyRecord.get('terminalid'));
    //            gettreenode.select();

    //            var sindex = store.find("id", MyRecord.get('terminalid'))
    //            if (sindex != -1) {
    //                rsm.selectRow(sindex);
    //                var gv = grid.getView();
    //                gv.focusRow(sindex);
    //            }
    //            if ((MyRecord.get('jpjdx') != 0) && (MyRecord.get('jpwdy') != 0)) {
    //                window.frames["movemark"].setCenter(MyRecord.get('jpjdx'), MyRecord.get('jpwdy'));
    //                window.frames["movemark"].setLatLng2(MyRecord.get('jpjdx'), MyRecord.get('jpwdy'));
    //                window.frames["movemark"].getAddress(MyRecord.get('jpjdx'), MyRecord.get('jpwdy'), 1);
    //            } else {
    //                window.frames["movemark"].setCenter(MyRecord.get('jdx'), MyRecord.get('wdy'));
    //                window.frames["movemark"].setLatLng2(MyRecord.get('jdx'), MyRecord.get('wdy'));
    //                window.frames["movemark"].getAddress(MyRecord.get('jdx'), MyRecord.get('wdy'), 1);
    //            }
    //            window.frames["movemark"].openInfoWindow();
    //            window.frames["movemark"].selmarker_show();
    //        }

    //    });

Confirmed_grid.hide();

if (currentService != 5) {
    TabPanel2 = new Ext.TabPanel({
        border: false, // already wrapped so don't add another border
        activeTab: 0, // second tab initially active
        tabPosition: 'bottom',
        items: [{
            //html: '<p>A TabPanel component can be a region.</p>',
            //contentEl: 'Unrecognized',
            title: '未确认',
            //autoScroll: true,
            layout: 'fit',
            items: Unrecognized_grid
        }, {
            //html: '<p>b TabPanel component can be a region.</p>',
            //contentEl: 'Confirmed',
            title: '已确认',
            //autoScroll: true
            layout: 'fit',
            items: Confirmed_grid
        }]
    });
    TabPanel2.on("tabchange", function () {//
        if (t1 == 1) {
            Confirmed_grid.show();
        } else {
            t1 = 1;
        }
    });
} else {
    TabPanel2 = new Ext.Panel({
        layout: 'fit',
//        border: false, // already wrapped so don't add another border
//        activeTab: 0, // second tab initially active
//        tabPosition: 'bottom',
        items: Unrecognized_grid
});
}
iniAlarm();

function inicmbAlarmBtnConfirm() {
    if (currentService != 5) {
        return { icon: "images/accept.png", text: "",
            handler: querenALLjingqing,
            tooltip: "确认所有报警", tooltipType: "title"
        };
    }
    return "";
}
function inicmbAlarmBtnConfirmDel() {
    if (currentService != 5) {
        return { icon: "images/cross.gif", text: "",
                        handler: clearALLjingqing,
                        tooltip: "删除所有已确认报警", tooltipType: "title"
                    };
    }
    return "";
}
        return new Ext.Panel({
            id: "east-panel",
            region: "east",
            width: 200,
            split: true,
            collapsible: true,
            title: "报警信息----报警提示已开启",
            bbar: [
                    { icon: "images/nobubble.png", text: "",
                        handler: pbjingqing,
                        tooltipType: "title", tooltip: "关闭提示"
                    },
                    { icon: "images/comment.gif", text: "",
                        handler: jsjingqing,
                        tooltip: "打开提示",
                        tooltipType: "title"
                    }, inicmbAlarmBtnConfirm(),inicmbAlarmBtnConfirmDel(), { icon: "images/acceptcheck.png", text: "",
                        handler: function() {
                            if (Ext.getCmp('app-alarm-panel') == null) {
                                var alarmQueryPanel = createAlarmQueryPanel();
//                                var alarmQueryPanel = new Ext.Panel({
//                                                                    title: '报警查询',
//                                                                    iconCls: 'tabs',
//                                                                    id: 'app-alarm-panel',
//                                                                    anchor: '100% 100%',
//                                                                    html: "<IFRAME  border='0' id='PageAlarmQuery' name='historyPlay' src='QueryPage/PageAlarmQuery.aspx' frameBorder='0' width='100%' height='100%' scrolling='no'></IFRAME>",
//                                                                    closable: true
//                                                                });
                                mapPanel.add(alarmQueryPanel);
                            }
                            mapPanel.setActiveTab('app-alarm-panel');
                        },
                        tooltip: "报警查询", tooltipType: "title"
                    }
                   ],
            layout: 'fit', // specify layout manager for items
            items: TabPanel2          // this TabPanel is wrapped by another Panel so the title will be applied
        });
    }



    function rightClickFn1(grid, rowindex, e) {
        grid.getSelectionModel().selectRow(rowindex);
        e.preventDefault();
        rightClick1.showAt(e.getXY());
        dq_jingqing_id = rowindex;
    }
    function rightClickFn2(grid, rowindex, e) {
        grid.getSelectionModel().selectRow(rowindex);
        e.preventDefault();
        rightClick2.showAt(e.getXY());
        dq_jingqing_id = rowindex;
    }
    //冒泡提示
    Ext.ns('Ext.ux');
    /** 
    * 右下角的小贴士窗口
    * @author tipx.javaeye.com
    * @params conf 参考Ext.Window
    *         conf中添加autoHide配置项, 默认3秒自动隐藏, 设置自动隐藏的时间(单位:秒), 不需要自动隐藏时设置为false
    * @注: 使用独立的window管理组(manager:new Ext.WindowGroup()), 达到总是显示在最前的效果
    */
    ; (function($) {
        //新建window组，避免被其它window影响显示在最前的效果
        var tipsGroupMgr = new Ext.WindowGroup();
        tipsGroupMgr.zseed = 99999; //将小贴士窗口前置

        $.TipsWindow = Ext.extend(Ext.Window,
    {
        width: 200,
        height: 150,
        layout: 'fit',
        modal: false,
        plain: true,
        shadow: false,
        //去除阴影
        draggable: false,
        //默认不可拖拽
        resizable: false,
        closable: true,
        closeAction: 'hide',
        //默认关闭为隐藏
        autoHide: 3,
        count: 1, //设置显示的是第几个tipwindow
        //n秒后自动隐藏，为false时,不自动隐藏
        manager: tipsGroupMgr,
        //设置window所属的组
        constructor: function(conf) {
            $.TipsWindow.superclass.constructor.call(this, conf);
            this.initPosition(true);
        },
        initEvents: function() {
            $.TipsWindow.superclass.initEvents.call(this);
            //自动隐藏
            if (false !== this.autoHide) {
                var task = new Ext.util.DelayedTask(this.hide, this),
                second = (parseInt(this.autoHide) || 3) * 1000;
                this.on('beforeshow',
                function(self) {
                    task.delay(second);
                });
            }
            this.on('beforeshow', this.showTips);
            this.on('beforehide', this.hideTips);

            Ext.EventManager.onWindowResize(this.initPosition, this); //window大小改变时，重新设置坐标
            Ext.EventManager.on(window, 'scroll', this.initPosition, this); //window移动滚动条时，重新设置坐标
        },
        //参数: flag - true时强制更新位置
        initPosition: function(flag) {
            if (true !== flag && this.hidden) { //不可见时，不调整坐标
                return false;
            }
            var doc = document,
            bd = (doc.body || doc.documentElement);
            //ext取可视范围宽高(与上面方法取的值相同), 加上滚动坐标
            var left = bd.scrollLeft + Ext.lib.Dom.getViewWidth() - 4 - this.width;
            var top = bd.scrollTop + Ext.lib.Dom.getViewHeight() - 4 - this.height * this.count;
            this.setPosition(left, top);
        },
        showTips: function() {
            var self = this;
            if (!self.hidden) {
                return false;
            }

            self.initPosition(true); //初始化坐标
            self.el.slideIn('b',
            {
                callback: function() {
                    //显示完成后,手动触发show事件,并将hidden属性设置false,否则将不能触发hide事件
                    self.fireEvent('show', self);
                    self.hidden = false;
                }
            });
            return false; //不执行默认的show
        },
        hideTips: function() {
            var self = this;
            if (self.hidden) {
                return false;
            }

            self.el.slideOut('b',
            {
                callback: function() {
                    //渐隐动作执行完成时,手动触发hide事件,并将hidden属性设置true
                    self.fireEvent('hide', self);
                    self.hidden = true;
                }
            });
            return false; //不执行默认的hide
        }
    });
    })(Ext.ux);

    function bubbleshow() {
        tipw[abc] = new Ext.ux.TipsWindow(
    {
        title: "报警提示",
        autoHide: 5,
        count: abc + 1, //设置弹出的是第几个
        //5秒自动关闭
        html: getAlarmhtml()
    });
        tipw[abc].show();
        //soundManager.play('systemSound');
        play();
        //hideorshowPanel();
    }

    //播放声音，需要在窗体添加如下代码
    //<bgsound loop="1" id="bgs"/> 
    //跨浏览器主要是FF参照http://www.cnblogs.com/joe_sky/archive/2010/12/17/1909095.html
    function play() {
        //注意文件路径，且文件大小一般10kb以内
        document.all.bgs.src = './sound/alarm.wav';
    }

    function hideorshowPanel() {
        // get a reference to the Panel that was created with id = 'west-panel'
        var w = Ext.getCmp('east-panel');
        // expand or collapse that Panel based on its collapsed property state
        w.collapsed ? w.expand() : w.collapse();
    }

    function getAlarmhtml() {
        var w = Ext.getCmp('east-panel');
        if (w.collapsed)
            return "<a onclick=hideorshowPanel()>有" + intNewAlarmCount + "条报警信息未处理，点击查看</a>";
        else
            return "有" + intNewAlarmCount + "条报警信息未处理";
    }

    function copyAlarmStore() {
        //LastUnrecognized_store = new Ext.data.Store();//new一下也不可以
        //LastUnrecognized_store = Unrecognized_store;//指针复制，前者根据后者变化而变化
        LastUnrecognized_store.removeAll();
        for (var i = 0; i < Unrecognized_store.getCount(); i++) {
            var recordnew = Unrecognized_store.getAt(i);
            LastUnrecognized_store.add(recordnew);
        }
    }

    function getNewAlarmCount() {
        intNewAlarmCount = 0;
        //只有在jingqing == 1，既打开接收警情的时候才比较，否则不比较
        if (jingqing == 1) {
            for (var i = 0; i < Unrecognized_store.getCount(); i++) {
                var recordnew = Unrecognized_store.getAt(i);
                var rowidnew = recordnew.get('ROWID');
                var isin = false;
                for (var j = 0; j < LastUnrecognized_store.getCount(); j++) {
                    var recordold = LastUnrecognized_store.getAt(j);
                    var rowidold = recordold.get('ROWID');
                    if (rowidnew == rowidold) {
                        isin = true;
                        break;
                    }
                }
                if (isin == false)
                    intNewAlarmCount++;
            }
        }
        //alert("intNewAlarmCount" + intNewAlarmCount);
        if (intNewAlarmCount > 0)
            bubbleshow();
        return intNewAlarmCount;
    }

    function pbjingqing() {
        jingqing = 0;
        Ext.Msg.alert('提示！', '报警提示已关闭');
        var w = Ext.getCmp('east-panel');
        Ext.getCmp("east-panel").setTitle("报警信息----报警提示已关闭");
        //        alert(w.title);
    }

    function jsjingqing() {
        jingqing = 1;
        Ext.Msg.alert('提示！', '报警提示已开启');
        Ext.getCmp("east-panel").setTitle("报警信息----报警提示已开启");
    }

    function clearALLjingqing() {
        //首先获取所有的ROWID
        var alarmid = "";
        for (var i = 0; i < Confirmed_store.getCount(); i++) {
            var recordtemp = Confirmed_store.getAt(i);
            var rowidtemp = recordtemp.get('ROWID');
            alarmid = alarmid + rowidtemp + ",";
        }
        if (alarmid == "")
            Ext.Msg.alert('提示！', '没有已确认的报警信息');
        //执行操作
        if (alarmid != "") {
            Ext.Ajax.request({
                url: "./Json/JsonGetAlarmInfoList.ashx",
                params: {
                alarmIDList: alarmid, clientNo: userClientNo, op: 'AlarmInfoDelBatch'
                },
                success: function(response, options) {
                    Confirmed_store.removeAll();
                    if ((Unrecognized_store.getCount() == 0) && (Confirmed_store.getCount() == 0)) {
                        TabPanel2.setActiveTab(0);
                        alarmPanel.collapse();
                    }
                    Ext.Msg.alert('提示！', '操作成功');
                },
                failure: function() {
                    Ext.Msg.alert("错误", "与后台联系的时候出现了问题");
                }
            });
        }
    }


    function clearjingqing() {
        if (dq_jingqing_id != -1) {
            var recordtemp = Confirmed_store.getAt(dq_jingqing_id);
            var rowidtemp = recordtemp.get('ROWID');

            //操作数据库确认所有的警情
            var alarmid = "";
            var rowidtemp = recordtemp.get('ROWID');
            alarmid = alarmid + rowidtemp + ",";

            if (alarmid == "")
                Ext.Msg.alert('提示！', '没有已确认的报警信息');
            //执行操作
            if (alarmid != "") {
                Ext.Ajax.request({
                    url: "./Json/JsonGetAlarmInfoList.ashx",
                    params: {
                    alarmIDList: alarmid, clientNo: userClientNo, op: 'AlarmInfoDelBatch'
                    },
                    success: function(response, options) {
                        Confirmed_store.removeAt(dq_jingqing_id);
                        if ((Unrecognized_store.getCount() == 0) && (Confirmed_store.getCount() == 0)) {
                            TabPanel2.setActiveTab(0);
                            alarmPanel.collapse();
                        }
                        Ext.Msg.alert('提示！', '操作成功');
                    },
                    failure: function() {
                        Ext.Msg.alert("错误", "与后台联系的时候出现了问题");
                    }
                });
            }
        }
    }
    function querenALLjingqing() {
        //首先添加所有实时警情给Confirmed_store
        for (var i = 0; i < Unrecognized_store.getCount(); i++) {
            var recordnew = Unrecognized_store.getAt(i);
            Confirmed_store.add(recordnew);
        }
        //操作数据库确认所有的警情
        var alarmid = "";
        for (var i = 0; i < Unrecognized_store.getCount(); i++) {
            var recordtemp = Unrecognized_store.getAt(i);
            var rowidtemp = recordtemp.get('ROWID');
            alarmid = alarmid + rowidtemp + ",";
        }
        if (alarmid == "")
            Ext.Msg.alert('提示！', '没有未确认的报警信息');

        if (alarmid != "") {
            Ext.Ajax.request({
                url: "./Json/JsonGetAlarmInfoList.ashx",
                params: {
                alarmIDList: alarmid, operators: userName, disposition: "", clientNo: userClientNo, op: 'AlarmInfoConfirmBatch'
                },
                success: function(response, options) {
                    //清空实时警情store
                    Unrecognized_store.removeAll();
                    if ((Unrecognized_store.getCount() == 0) && (Confirmed_store.getCount() == 0)) {
                        TabPanel2.setActiveTab(0);
                        alarmPanel.collapse();
                    }
                    Ext.Msg.alert('提示！', '操作成功');
                },
                failure: function() {
                    Ext.Msg.alert("错误", "与后台联系的时候出现了问题");
                }
            });
        }
    }

    function querenjingqing() {
        //首先添加所有实时警情给Confirmed_store
        if (dq_jingqing_id != -1) {
            var recordtemp = Unrecognized_store.getAt(dq_jingqing_id);
            Confirmed_store.add(recordtemp);
            //操作数据库确认所有的警情
            var alarmid = "";
            var rowidtemp = recordtemp.get('ROWID');
            alarmid = alarmid + rowidtemp + ",";

            if (alarmid == "")
                Ext.Msg.alert('提示！', '没有未确认的报警信息');

            if (alarmid != "") {
                Ext.Ajax.request({
                    url: "./Json/JsonGetAlarmInfoList.ashx",
                    params: {
                    alarmIDList: alarmid, operators: userName, disposition: "", clientNo: userClientNo, op: 'AlarmInfoConfirmBatch'
                    },
                    success: function(response, options) {
                        //清空实时警情store
                        Unrecognized_store.removeAt(dq_jingqing_id);
                        if ((Unrecognized_store.getCount() == 0) && (Confirmed_store.getCount() == 0)) {
                            TabPanel2.setActiveTab(0);
                            alarmPanel.collapse();
                        }
                        Ext.Msg.alert('提示！', '操作成功');
                    },
                    failure: function() {
                        Ext.Msg.alert("错误", "与后台联系的时候出现了问题");
                    }
                });
            }
        }
    }

